package vodka.interpreter;

import org.apache.bcel.generic.*;
import org.apache.bcel.classfile.*;
import org.apache.bcel.*;
import java.io.*;

/**
 *	Code to re-build class NativeHookTemplate at runtime. 
 *	Output from the bcelify tool.
 */

public class NativeHookTemplateCreator implements Constants {
  private InstructionFactory _factory;
  private ConstantPoolGen    _cp;
  private ClassGen           _cg;

  public NativeHookTemplateCreator() {
    _cg = new ClassGen("vodka.interpreter.NativeHookTemplate", "vodka.interpreter.NativeHook", "NativeHookTemplate.java", ACC_PUBLIC | ACC_SUPER, new String[] {  });

    _cp = _cg.getConstantPool();
    _factory = new InstructionFactory(_cg, _cp);
  }

  public void create(OutputStream out) throws IOException {
    createMethod_0();
    createMethod_1();
    createMethod_2();
    createMethod_3();
    createMethod_4();
    createMethod_5();
    createMethod_6();
    createMethod_7();
    createMethod_8();
    createMethod_9();
    createMethod_10();
    createMethod_11();
    createMethod_12();
    _cg.getJavaClass().dump(out);
  }

  private void createMethod_0() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] {  }, "<init>", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0));
    il.append(_factory.createInvoke("vodka.interpreter.NativeHook", "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
    InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_1() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeCons0", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createNew("vodka.interpreter.NativeTemplate"));
    il.append(InstructionConstants.DUP);
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
    InstructionHandle ih_7 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_2() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeCons1", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createNew("vodka.interpreter.NativeTemplate"));
    il.append(InstructionConstants.DUP);
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "<init>", Type.VOID, new Type[] { new ObjectType("vodka.interpreter.NativeTemplate") }, Constants.INVOKESPECIAL));
    InstructionHandle ih_13 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_3() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeCons2", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createNew("vodka.interpreter.NativeTemplate"));
    il.append(InstructionConstants.DUP);
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 1));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "<init>", Type.VOID, new Type[] { new ObjectType("vodka.interpreter.NativeTemplate"), new ObjectType("vodka.interpreter.NativeTemplate") }, Constants.INVOKESPECIAL));
    InstructionHandle ih_19 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_4() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeVirtual0", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createStore(Type.OBJECT, 2));
    InstructionHandle ih_7 = il.append(_factory.createLoad(Type.OBJECT, 2));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodVirtual0", new ObjectType("vodka.interpreter.NativeTemplate"), Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    InstructionHandle ih_11 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_5() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeVirtual1", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createStore(Type.OBJECT, 2));
    InstructionHandle ih_7 = il.append(_factory.createLoad(Type.OBJECT, 2));
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 1));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodVirtual1", new ObjectType("vodka.interpreter.NativeTemplate"), new Type[] { new ObjectType("vodka.interpreter.NativeTemplate") }, Constants.INVOKEVIRTUAL));
    InstructionHandle ih_17 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_6() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeVirtual2", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createStore(Type.OBJECT, 2));
    InstructionHandle ih_7 = il.append(_factory.createLoad(Type.OBJECT, 2));
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 1));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 2));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodVirtual2", new ObjectType("vodka.interpreter.NativeTemplate"), new Type[] { new ObjectType("vodka.interpreter.NativeTemplate"), new ObjectType("vodka.interpreter.NativeTemplate") }, Constants.INVOKEVIRTUAL));
    InstructionHandle ih_23 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_7() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeVoidStatic0", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodVoidStatic0", Type.VOID, Type.NO_ARGS, Constants.INVOKESTATIC));
    InstructionHandle ih_3 = il.append(_factory.createLoad(Type.OBJECT, 0));
    il.append(_factory.createFieldAccess("vodka.interpreter.NativeHookTemplate", "unit", Type.OBJECT, Constants.GETFIELD));
    InstructionHandle ih_7 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_8() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeStatic0", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodStatic0", new ObjectType("vodka.interpreter.NativeTemplate"), Type.NO_ARGS, Constants.INVOKESTATIC));
    InstructionHandle ih_3 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_9() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeStatic1", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodStatic1", new ObjectType("vodka.interpreter.NativeTemplate"), new Type[] { new ObjectType("vodka.interpreter.NativeTemplate") }, Constants.INVOKESTATIC));
    InstructionHandle ih_9 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_10() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeStatic2", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 1));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("vodka.interpreter.NativeTemplate")));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodStatic2", new ObjectType("vodka.interpreter.NativeTemplate"), new Type[] { new ObjectType("vodka.interpreter.NativeTemplate"), new ObjectType("vodka.interpreter.NativeTemplate") }, Constants.INVOKESTATIC));
    InstructionHandle ih_15 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_11() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeBasicStatic2", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("java.lang.Integer")));
    il.append(_factory.createInvoke("java.lang.Integer", "intValue", Type.INT, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 1));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ObjectType("java.lang.Boolean")));
    il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodBasicStatic2", Type.FLOAT, new Type[] { Type.INT, Type.BOOLEAN }, Constants.INVOKESTATIC));
    il.append(_factory.createInvoke("java.lang.Float", "valueOf", new ObjectType("java.lang.Float"), new Type[] { Type.FLOAT }, Constants.INVOKESTATIC));
    InstructionHandle ih_24 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_12() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC, Type.OBJECT, new Type[] { new ArrayType(Type.OBJECT, 1) }, new String[] { "arg0" }, "invokeArrayStatic2", "vodka.interpreter.NativeHookTemplate", il, _cp);

    InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 0));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ArrayType(Type.INT, 1)));
    il.append(_factory.createCheckCast(new ArrayType(Type.INT, 1)));
    il.append(_factory.createLoad(Type.OBJECT, 1));
    il.append(new PUSH(_cp, 1));
    il.append(InstructionConstants.AALOAD);
    il.append(_factory.createCheckCast(new ArrayType(Type.STRING, 1)));
    il.append(_factory.createCheckCast(new ArrayType(Type.STRING, 1)));
    il.append(_factory.createInvoke("vodka.interpreter.NativeTemplate", "methodArrayStatic2", new ArrayType(Type.INT, 1), new Type[] { new ArrayType(Type.INT, 1), new ArrayType(Type.STRING, 1) }, Constants.INVOKESTATIC));
    InstructionHandle ih_21 = il.append(_factory.createReturn(Type.OBJECT));
    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  public static void main(String[] args) throws Exception {
    vodka.interpreter.NativeHookTemplateCreator creator = new vodka.interpreter.NativeHookTemplateCreator();
    creator.create(new FileOutputStream("vodka.interpreter.NativeHookTemplate.class"));
  }
}
